﻿using Furion;
using Furion.DynamicApiController;
using GWB.Application.Common;
using GWB.Application.System.TenantManage.Dtos;
using GWB.Application.System.TenantManage.TenantService;
using GWB.Core;
using GWB.Core.Enum;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWB.Application.System.TenantManage
{
    /// <summary>
    /// 租户管理
    /// </summary>
    [ApiDescriptionSettings("系统管理", Tag = "租户管理", SplitCamelCase = false)]
    public  class TenantAppService: IDynamicApiController
    {
        /// <summary>
        ///新增
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "新增租户",Code = AuthCode.Add)]
        public async Task<Result<TenantOutDto>> Add(TenantCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<ITenantService>().Add(inputDto);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "修改租户")]
        public async Task<bool> Update(TenantCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<ITenantService>().Update(inputDto);
        }



        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [Authorization(Name = "删除租户")]
        public async Task<bool> Delete(List<long> ids)
        {
            return await App.GetService<ITenantService>().Delete(ids);

        }


        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "查询租户")]
        public async Task<PageResult<TenantOutDto>> Page(TenantPageInputDto inputDto)
        {
            return await App.GetService<ITenantService>().Page(inputDto);
        }

        /// <summary>
        /// 编辑租户菜单
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "编辑租户菜单", Code = AuthCode.None)]
        public async Task<bool> EditTenantMenu(TenantMenuEditInputDto inputDto)
        {
            return await App.GetService<ITenantService>().EditTenantMenu(inputDto);
        }

        /// <summary>
        /// 获取租户的菜单
        /// </summary>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        [Authorization(Name = "获取租户菜单", Code = AuthCode.None)]
        public async Task<List<TenantMenuOutDto>> GetTenantMenus(long tenantId)
        {
            return await App.GetService<ITenantService>().GetTenantMenus(tenantId);
        }
    }
}
